﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using DragDraw.Util;

namespace DragDraw.Tool
{
    public partial class PageTextInstance : UserControl
    {
        private PageText m_pageText;

        private WidgetServiceProxy m_service;

        internal PageText PageText
        {
            get { return m_pageText; }
            set
            {
                m_pageText = value;
                TxtEdit.Text = value.Content;
                TxtPresent.Text = value.Content;
            }
        }
        public PageTextInstance()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            m_service = OperationManager.Instance.CreateWidgetServiceProxy(this);
            m_service.GetSessionCompleted += OnGetSession;
            m_service.SetSessionCompleted += OnSetSession;
            m_service.GetSession("text");
        }

        void OnSetSession(object sender, DragDraw.UserService.SetSessionCompletedEventArgs e)
        {
            
        }

        void OnGetSession(object sender, DragDraw.UserService.GetSessionCompletedEventArgs e)
        {
            
        }

        private void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            TxtPresent.Text = TxtEdit.Text;
            PanelEdit.Visibility = Visibility.Collapsed;
            m_service.SetSession("text", TxtEdit.Text);
        }

        private void TxtPresent_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (WidgetHelper.IsInMySpace)
            {
                PanelEdit.Visibility = Visibility.Visible;
            }
        }
    }

    public class PageText
    {
        public string Content { get; set; }
        public int PosX { get; set; }
        public int PosY { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }
    }
}
